<template>
  <view>
    <!-- 轮播图 -->
    <uv-swiper :list="list" indicator indicatorMode="line" circular></uv-swiper>
  </view>

  <uv-divider text="待办事项" text-size="30rpx" textPosition="left"></uv-divider>

  <uv-divider text="沟通记录" text-size="30rpx" textPosition="left"></uv-divider>
  <!-- <template class="body-container"> -->
  <uv-list class="body-container">
    <!-- <uv-list-item title="列表文字" right-text="blablabla"></uv-list-item> -->
    <template v-for="item in commentList" :key="item.id" >
      <uv-list-item :title="item.content" :ellipsis="1"  :note="item.subject" :right-text="`沟通时间：${item.ctime}`" link :to="item.link">
      <!-- <uv-list-item :title="item.content" :note="item.content" ellipsis=3 right-text="沟通时间" link to=""> -->
      </uv-list-item>
    </template>
  </uv-list>
  <!-- </view> -->

  <uv-divider text="机会跟踪" text-size="30rpx" textPosition="left"></uv-divider>
  <uv-list class="body-container">
    <!-- <uv-list-item title="列表文字" right-text="blablabla"></uv-list-item> -->
    <template v-for="i in 8">
      <uv-list-item :title="`项目名称是项目名称${i}`" note="客户名称全称或简称" right-text=""
        thumb="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png" link to="">
      </uv-list-item>
    </template>
  </uv-list>
</template>

<script setup>
  import {
    onLoad,
    onShow
  } from "@dcloudio/uni-app";
  import {
    getCurrentInstance,
    ref
  } from 'vue'
  import nx from "@/nx";

  let list = ref([
    'https://cdn.uviewui.com/uview/swiper/swiper3.png',
    'https://cdn.uviewui.com/uview/swiper/swiper2.png',
    'https://cdn.uviewui.com/uview/swiper/swiper1.png',
  ])

  const commentApi = nx.$api.comment
  const commentList = ref([])
  onShow(
    async () => {
      let resp = await commentApi.getCommentList()
      console.log(resp.data[0].create_time);
      const result = resp.data.map((item) => {
        return {
          subject: item.subject, 
          content:item.content, 
          ctime:item.create_time, 
          id:item._id,
          link: `/pages/display/CommentDetail?id=${item._id}`
          }
      })
      console.log(result);
      commentList.value = result
      // console.log('平路', resp.data);
    })
  // export default {
  // 	setup(props, context) {
  // 		const {
  // 			proxy
  // 		} = getCurrentInstance()
  // 		onLoad((option) => {

  // 		})
  // 		onShow(() => {})
  // 	}
  // }
</script>

<style lang="scss" scoped>
  .uv-divider {
    margin: 50rpx auto;
  }
</style>